package com.jing.my;

import android.content.Context;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
public class FirstActivity extends AppCompatActivity {
	MaterialButton mb;
//	TextInputEditText tt;
	Context c;
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.first);
		c=this;
		initview();
		mb.setOnClickListener(v -> {
		
			View a=View.inflate(FirstActivity.this,R.layout.dialog,null);
			TextInputEditText tt=a.findViewById(R.id.text);
			new MaterialAlertDialogBuilder(FirstActivity.this)
					.setTitle("This is a Dialog")
					.setView(a)
					.setPositiveButton("Ok",(c,d)->{a("android.permission."+tt.getText().toString());})
					.setCancelable(false)
					.show();
			
	});
	}
void a(String s)
		
		{
			XXPermissions.with(this).permission(s).request(
			(a,b)->
			{
				
				Toast.makeText(getApplicationContext(),"giao",Toast.LENGTH_SHORT).show();
				}
			
			);
		
			}
	void initview() {
		mb = findViewById(R.id.bt);
	//	tt=findViewById(R.id.text);
	}
}